﻿using AutoCADDotNetLibrary;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Interop;

namespace $safeprojectname$
{
    public class ComMenu
    {
        private static AcadPopupMenu _comMenu;

        [ComMenuInitialize]
        public void ShowMenu()
        {
            AcadApplication acadApp = (AcadApplication)Application.AcadApplication;
            //没有时，添加根菜单
            if (_comMenu == null)
            {
                _comMenu = acadApp.MenuGroups.Item(0).Menus.Add("hello");

                //添加功能
                _comMenu.AddAcadPopupMenuItem(typeof(Hello));
            }

            //将定义的菜单显示在AutoCAD菜单栏的最后
            if (!_comMenu.OnMenuBar)
            {
                _comMenu.InsertInMenuBar(acadApp.MenuBar.Count);
            }
        }
    }
}
